/* 
This do file produces the summary statistics for Table 1.
NOTES:

*/

clear all

*change "mainpath" below to your folder location
global mainpath `"Z:/user/rih4/Solar Siting"'

*shouldn't need to change these paths if your folders are named the same
cd `"${mainpath}/JAERE Code Repository"'
global data_path `"Data JAERE"'
global data_intermediate `"${data_path}/intermediate_output"'
global data_final `"${data_path}/final_output"'

import delimited `"${data_path}/Generation_and_damages_withCO2_2021-03-05_eGrid_SR.csv"'

gen subsidy_value = subsidy_kwh*total_generation*1000

gen total_generation_kWh = total_generation*1000

*Table 1:
estpost sum total_generation_kWh total_damages CO2 NOx PM25 SO2 subsidy_value NET genval_severin
esttab using `"${data_final}/table1.csv"', cells("mean sd min max") replace

*Footnote below Table 1 (mean annual subsidy weighted by number of panels in each zip):
quietly: sum num_systems
gen wt_subsidy_value = subsidy_value*num_systems/r(sum)
quietly: sum wt_subsidy_value
di r(sum)

quietly: sum num_systems
gen wt_NET = NET*num_systems/r(sum)
quietly: sum wt_NET
di r(sum)